<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
    <jsp:include page="../common/common.jsp"/>
</head>
<body class="page-header-fixed">
<jsp:include page="../common/header.jsp"/>
<div class="clearfix">
</div>
<div class="page-container">
    <div class="page-sidebar-wrapper"><jsp:include page="../common/menu.jsp"/></div>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <form class="form-horizontal form-row-seperated" id="form" method="post" action="${path}/taps/save">
                        <div class="portlet box purple">
                            <div class="portlet-title">
                                <div class="caption">
                                    <i class="fa fa-shopping-cart"></i>详细内容
                                </div>
                                <div class="actions btn-set">
                                    <a href="javascript:history.go(-1);" class="btn default"><i
                                            class="fa fa-angle-left"></i> 返回</a>
                                    <a href="javascript:location.reload();" class="btn green"><i
                                            class="fa fa-reply"></i> 重置</a>
                                    <button type="button" onclick="save()" class="btn blue"><i class="fa fa-check"></i> 
                                    </button>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <div class="tabbable">
                                    <div class="tab-content no-space">
                                        <div class="tab-pane active" id="tab_general">
                                            <div class="form-body">
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">栏目:
                                                        <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-3">
                                                              <select id="pid" class="form-control" name="pid">
                                                            <c:forEach items="${column}" var="s">
                                                            <c:if test="${s.id==10404}">
                                                                <option value="${s.id}"
                                                                <c:if test="${data.cv.pid==0}">
                                                                        <c:if test="${data.cv.id == s.id}">selected</c:if> >${s.value0}</option></c:if>
                                                                <c:if test="${data.cv.pid!=0}">
                                                                        <c:if test="${data.cv.pid == s.id}">selected</c:if> >${s.value0}</option></c:if>
                                                            </c:if>
                                                       
                                                            </c:forEach>
                                                        </select>
                                                    </div>
                                                    
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">标题:
                                                        <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="title" name="title"
                                                               class="form-control measure-input" datatype="*1-80"
                                                               value="${data.title}"/>
                                                    </div>
                                                    <div class="col-md-5">
                                                        &nbsp;可输入<b><span id="title_len">80</span></b> 个字符
                                                    </div>
                                                </div>
                                   <div class="form-group">
                                                    <label class="col-md-2 control-label">审核步骤:
                                                    </label>

                                                    <div class="col-md-3">
                                                        <select name="audit1Status" class="form-control" >
                                                        	<option value="0" <c:if test="${0== data.audit1Status }">selected="selected" </c:if> >未审核</option>
                                                            <option value="1" <c:if test="${1== data.audit1Status }">selected="selected" </c:if> >一级审核</option>
                                                            <option value="2" <c:if test="${2== data.audit1Status }">selected="selected" </c:if> >二级审核</option>
                                                        </select>
                                                    </div>
                                                    <label class="col-md-2 control-label">审核状态:
                                                    </label>

                                                    <div class="col-md-3">
                                                        <select name="audit2Status" class="form-control" >
                                                            <option value="1" <c:if test="${1== data.audit2Status }">selected="selected" </c:if> >审核不通过</option>
                                                            <option value="2" <c:if test="${2== data.audit2Status }">selected="selected" </c:if> >审核通过</option>
                                                        </select>
                                                    </div>
                                                   </div>
                                                   
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">发布时间:
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input id="falseCreateTime" name="falseCreateTime" type="text"
                                                               class="form-control tags medium"
                                                               value="${fn:substring(data.falseCreateTime,0,19)}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">置顶:
                                                    </label>
                                                    <div class="col-md-3">
                                                        <select name="status" class="form-control">
                                                            <option value="1">请选择</option>
                                                            <option value="3" <c:if test="${3== data.status }">selected="selected" </c:if> >置顶</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <input type="hidden" name="author" class="form-control"
                                                       value="admin"/>
                                                <!-- <input type="hidden" id="status" name="status" class="form-control"
                                                       value="1"/> -->
                                                <input type="hidden" id="imgUrl" name="imgUrl" class="form-control"
                                                       value="${data.imgUrl}"/>
                                                
                                                <%-- <c:if test="${data.columnId==9986 || data.columnId==9920 || data.columnId==9921 || data.columnId==9922 }"> --%>
                                                <div class="form-group">
                                                <label class="col-md-2 control-label">封面：</label>

                                                <div class="col-md-8">
                                                    <div class="fileinput fileinput-new" data-provides="fileinput">
                                                        <div class="fileinput-new thumbnail" style="width: 300px; height: 150px;">
                                                            <img src="${data.imgUrl}">
                                                        </div>
                                                        <div class="fileinput-preview fileinput-exists thumbnail"
                                                             style="max-width: 300px; max-height: 150px;">
                                                        </div>
                                                        <div>
                                                            <span class="btn default btn-file">
                                                                <span class="fileinput-new">
                                                                     选择图片
                                                                </span>
                                                                <span class="fileinput-exists">
                                                                     修改图片
                                                                </span>
                                                                <input type="file" id="file" name="file"/>
                                                            </span>
                                                            <a href="#" class="btn default fileinput-exists"
                                                               data-dismiss="fileinput">
                                                                移除图片
                                                            </a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
											<%-- </c:if> --%>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">内容:
                                                        <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-8">
                                                        <%-- <jsp:include page="common/editor.jsp" /> --%>
                                                        <input id="context" type="hidden" name="context">
                                                        <script id="editor" type="text/plain"
                                                                style="height:500px;">${data.context}</script>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="portlet-title">
                                <div class="actions btn-set">
                                    <a href="javascript:history.go(-1);" class="btn default"><i
                                            class="fa fa-angle-left"></i> 返回</a>
                                    <a href="javascript:location.reload();" class="btn green"><i
                                            class="fa fa-reply"></i> 重置</a>
                                    <button type="button" onclick="save()" class="btn blue"><i class="fa fa-check"></i> 保存
                                    </button>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" id="id" name="id" value="${data.id}">
                   <input id="audit1Status" type="hidden" name="audit1Status" value="1">
                        
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="../common/footer.jsp"/>
<script type="text/javascript" src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery-inputmask/jquery.inputmask.bundle.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.input-ip-address-control-1.0.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/jquery.pwstrength.bootstrap/src/pwstrength.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/district/linkagesel-min.js"></script>

<script>
    var operType = '${operType}';
    var editor, form;
    $(function () {
        $('#pid').change(function() {
            changeSecondType(this.value);
        });
        changeSecondType($('#pid').val());
        function changeSecondType(pid) {
            $.ajax({
                url: _path + '/conf/queryConfTByPid?pid='+pid,
                type: 'GET',
                success: function(resp) {
                    $("#columnId").html('');
                    new LinkageSel({
                        dataReader: {id: 'id', name: 'value0'},
                        data: resp.dataList,
                        selStyle: 'margin-left: 3px;',
                        select:  '#columnId',
                        defVal: ['${data.columnId}']
                    });
                }
            });
        }

        UE.getEditor('editor');
        form = $("form").Validform({
            tiptype: function (msg, o, cssctl) {
                //msg：提示信息;
                //o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
                //cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
                if (!o.obj.is("form")) {//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
                    var objtip = o.obj.siblings(".Validform_checktip");
                    cssctl(objtip, o.type);
                    objtip.text(msg);
                } else {
                    var objtip = o.obj.find("#msgdemo");
                    cssctl(objtip, o.type);
                    objtip.text(msg);
                }
            },
            postonce: true,
            showAllError: true,
            callback: function () {
                save();
            }
        });
    });
    function save() {
        var context = UE.getEditor('editor').getContent();
        if (!/[\w\W]+/.test(context)) {
            alert("内容不能为空");
            return;
        }
        $("#context").val(context);
        
        if ($("#file").val() !== "") {
            $.ajaxFileUpload({
                url: '${path}/conf/upload',
                secureuri: false,
                fileElementId: 'file',
                dataType: 'json',
                success: function (data, status) {
                    if (data.statusCode == 200) {
                        $("#imgUrl").val(data.uri);
                        $("#form").submit();
                    } else
                        alert(data.info);
                }
            });
        }else{
	        $("#form").submit();
        }
        
    }
</script>
</body>
</html>